﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Spacebuilder.Common
{
    /// <summary>
    /// 短信模版维护
    /// </summary>
    public class SmsTemplatesService
    {
        private ISmsTemplatesRepository smstemplatesrepository;

        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        public SmsTemplatesService()
            : this(new SmsTemplatesRepository())
        {
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mailAddressRepository">邮寄信息仓储实现</param>
        public SmsTemplatesService(ISmsTemplatesRepository smstemplatesrepository)
        {
            this.smstemplatesrepository = smstemplatesrepository;
        }
        #endregion

        #region 短信模版维护
        /// <summary>
        /// 创建短信模版
        /// </summary>
        /// <param name="smstemplates">模版对象</param>
        /// <returns></returns>
        public bool Create(SmsTemplates smstemplates)
        {
            smstemplatesrepository.Insert(smstemplates);
            return smstemplates.id > 0;
        }

        /// <summary>
        /// 编辑模版对象
        /// </summary>
        /// <param name="smstemplates">编辑模版对象</param>
        public void Edit(SmsTemplates smstemplates)
        {
            smstemplatesrepository.Update(smstemplates);
        }

        /// <summary>
        /// 删除短信模版
        /// </summary>
        /// <param name="smstemplates"></param>
        public void Delete(SmsTemplates smstemplates)
        {
            smstemplatesrepository.Delete(smstemplates);
        }
        #endregion

        #region 邮寄地址查询
        /// <summary>
        /// 获取模版对象
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns>返回模版对象</returns>
        public SmsTemplates Get(int Id)
        {
            return smstemplatesrepository.Get(Id);
        }

        /// <summary>
        /// 返回模版对象列表
        /// </summary>
        /// <param name="userId">ID</param>
        /// <returns></returns>
        public IEnumerable<SmsTemplates> GetsOfUser(int id)
        {
            return smstemplatesrepository.GetSmsTemplates(id);
        }
        #endregion
    }
}
